﻿using System;
namespace FZKJ.ZHXJ.Models
{
    public class GenerateCode
    {
        public  static string GetCode()
        {
            string basecode = "ZHXJ" + DateTime.Now.ToString("yyyyMMdd");
            int number = 1;
            string code = basecode + number.ToString().PadRight(5, '0');

            while (true)
            {
                if (new BLL.buss_members().Exists(code))
                {
                    number++;
                    code = basecode + number.ToString().PadLeft(5, '0');
                }
                else
                {
                    break;
                }
            }

            return code;
        }
        public static string GetCardCode()
        {
            string basecode = "ZHXJ" + DateTime.Now.ToString("yyyyMMdd");
            int number = 1;
            string code = basecode + number.ToString().PadRight(5, '0');

            while (true)
            {
                if (new BLL.buss_card().Exists(code))
                {
                    number++;
                    code = basecode + number.ToString().PadRight(5, '0');
                }
                else
                {
                    break;
                }
            }

            return code;
        }
    }
}